﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace dpdw.Behaviour.IteratorPattern
{
    public class Waitress
    {
        private DinerMenu dinerMenu;
        private PancakeHouseMenu pancakeHouseMenu;

        public Waitress(PancakeHouseMenu pancakeHouseMenu,
            DinerMenu dinerMenu)
        {
            this.pancakeHouseMenu = pancakeHouseMenu;
            this.dinerMenu = dinerMenu;
        }

        public void PrintMenu()
        {
            Iterator pancakeIterator = pancakeHouseMenu.CreateIterator();
            Iterator dinerIterator = dinerMenu.CreateIterator();

            System.Diagnostics.Trace.WriteLine("====MENU====");

            System.Diagnostics.Trace.WriteLine("----BREAKFAST----");
            PrintMenu(pancakeIterator);

            System.Diagnostics.Trace.WriteLine("----LUNCH----");
            PrintMenu(dinerIterator);
        }

        private void PrintMenu(Iterator iterator)
        {
            while (iterator.HasNext())
            {
                MenuItem item = (MenuItem)iterator.Next();
                System.Diagnostics.Trace.WriteLine(item.Name);
            }
        }
    }
}
